<template>
    <div class="blog-header">
        <div class="nav">
           <div class="logo">
            <img src="@/assets/logo.png" alt="">
           </div>
           <div class="link">
            <router-link to="/home"> 首页 </router-link>
            <router-link to="/article"> 文章 </router-link>
            <router-link to="/conclude"> 归档 </router-link>
            <router-link to="about"> 关于 </router-link>
           </div>
        </div>
        <div class="contorl">
            <el-input :prefix-icon="Search"  v-model="inputSearch"  size="large" style="width: 240px" placeholder="搜索文章..." />
            <div class="user" v-if="!isLogin()">

               <router-link class="btn active" to="/login">登录</router-link>
               <router-link class="btn"to="/register">注册</router-link>
             </div>
             <div class="user"v-else>
                <div class="avatar">
                    <img :src="userInfo ? userInfo : baseAvatar " alt="">
                </div>
                

             </div>
        </div>
    </div>
    <div class="box"></div> 
</template>

<script setup>
import {ref} from 'vue'
import { Search } from '@element-plus/icons-vue'
import { isLogin } from '@/utils/isLogin';
import baseAvatar from '@/assets/vue.svg'

const inputSearch = ref('')
const userInfo = JSON.parse(localStorage.getItem('userInfo'))


</script>

<style lang="less" scoped>
.blog-header {
    box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.1);
    display: flex;
    height: 70px;
    justify-content: space-between;
    padding: 0 104px;
    position: fixed;
    top:0;
    width: 100%;
    box-sizing: border-box;
    background-color: #fff;
    z-index: 100;
    .nav{
        display: flex;
        align-items: center;
        .logo{
            width: 60px;
            img{
                width: 100%;
            }
        }
        .link{
            margin-left: 32px;

            a{
                font-size: 16px;
                color: #374151;
                margin-right: 24px;
                &.router-link-exact-active{
                    font-weight: 600;
                    font-size: 18px;
                    color: #8E6FF7;

                }
            }
        }
    }
    .contorl{
        display: flex;
        align-items: center;
        :deep(.el-input__wrapper){
            border-radius: 8px 8px 8px 8px;
            border: 1px solid #6B7280;
        }
        .user{
            .btn{
                display: inline-block;
                width: 64px;
                height: 40px;
                background: #E5E7EB;
                border-radius: 8px 8px 8px 8px;
                text-align: center;
                line-height: 40px;
                color: #080707;
                margin-left: 16px;
                &.active{
                    background: #8E6FF7;
                    color: #FFFFFF;
                }

            }
            .avatar{
                width: 32px;height: 32px;
                border-radius: 50%;
                overflow: hidden;
                margin-left: 16px;
                img{
                    width: 100%;
                }
            }
        }
    }
}
.box{
    height: 70px;
}


</style>